package elephant.servers.webserver.core;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * @author icecooly
 *
 */
public class PageAccessFilter implements Filter {
	/**
	 * 
	 */
	private static final Logger logger=LoggerFactory.getLogger(PageAccessFilter.class);
	@Override
	public void doFilter(ServletRequest theReq, ServletResponse theRep,
			FilterChain arg2) throws IOException, ServletException {
		HttpServletRequest req=(HttpServletRequest)theReq;
		HttpServletResponse rsp=(HttpServletResponse) theRep;
		String reqURI=req.getRequestURI();
		//
		logger.warn(req.getRemoteHost()+" try to access:"+reqURI);
		rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
	}
	@Override
	public void destroy() {
		
	}
	@Override
	public void init(FilterConfig arg0) throws ServletException {
		
	}
}
